SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE [dbo].[_ImportPODetails_GetByGRNId] @GRNId NVARCHAR(20)
AS 
    SELECT  ImportPODetails.POId ,
            ImportPODetails.DrugId ,
            ImportPODetails.RemainQuantity ,
            ImportPODetails.Remark ,
            ImportPODetails.PODetailId ,
            ImportPODetails.DrugName ,
            ImportPODetails.Unit ,
            ImportPODetails.CostPrice ,
            ImportPODetails.SellPrice ,
            ImportPODetails.MarkUpPercent ,
            ImportPODetails.MarkUpName ,
            ISNULL(GRNDetails.Quantity, 0) AS Quantity
    FROM    ImportPODetails
            LEFT OUTER JOIN GRNDetails ON ImportPODetails.DrugId = GRNDetails.DrugId
    WHERE   GRNId = @GRNId
GO
